<template>
    <div>
        <div class="container">
            <!-- 头部 -->
            <div class="nav">
                <div class="nav_wrap">
                    <div class="quit" @click="$router.back()"></div>
                    <span>充值</span>
                    <div class="nav_icon">
                        <router-link tag="a" to="/shelf"></router-link>
                        <i v-show="!isTop" @click="topShow"></i>
                        <i class="topnav" v-show="isTop" @click="topShow"></i>
                    </div>
                </div>
            </div>
            <div class="wrap" v-show="isTop" @click.self="topShow">
                <div class="subnav">
                    <ul>
                        <router-link tag="li" to="/">
                            <img src="../assets/images/tp_1.png" alt="">
                            <span>首页</span>
                        </router-link>
                        <router-link tag="li" to="/library">
                            <img src="../assets/images/tp_02.png" alt="">
                            <span>书库</span>
                        </router-link>
                        <router-link tag="li" to="/shelf">
                            <img src="../assets/images/tp_03.png" alt="">
                            <span>书架</span>
                        </router-link>
                        <router-link tag="li" to="/user">
                            <img src="../assets/images/tp_04.png" alt="">
                            <span>账户</span>
                        </router-link>
                        <router-link tag="li" to="/pay">
                            <img src="../assets/images/tp_05.png" alt="">
                            <span>充值</span>
                        </router-link>
                        <router-link tag="li" to="/search">
                            <img src="../assets/images/tp_06.png" alt="">
                            <span>搜索</span>
                        </router-link>
                    </ul>
                </div>
            
            </div>
            <!-- 充值介绍 -->
            <div class="set_money bor_bot">
                <p>账户余额：{{pay}}书币</p>
                <p>畅读截止时间：未开通畅读</p>
            </div>
            <!-- 充值选项 -->
            <div class="pay_option bor_bot">
                <div class="pay_tit">
                    <div :class="[paymode == 0? 'con' : '']" @click="paymode = 0">
                        微信
                    </div>
                    <div :class="[paymode == 1? 'con' : '']" @click="paymode = 1">
                        支付宝
                    </div>
                </div>
                <ul>
                    <li :class="[sum == 0? 'con':'']" @click="sum = 0">
                        <div class="head">
                            <h4>30元</h4>
                            <p>3000书币</p>
                        </div>
                        <div class="foot">
                        多送0元
                        </div>
                    </li>
                    <li :class="[sum == 1? 'con':'']" @click="sum = 1">
                        <div class="head">
                            <h4>50元</h4>
                            <p>5000书币+1000书币</p>
                        </div>
                        <div class="foot">
                        多送10元
                        </div>
                    </li>
                    <li :class="[sum == 2? 'con':'']" @click="sum = 2">
                        <div class="head">
                            <h4>100元</h4>
                            <p>10000书币+5000书币</p>
                        </div>
                        <div class="foot">
                        多送50元
                        </div>
                    </li>
                    <li :class="[sum == 3? 'con':'']" @click="sum = 3">
                        <div class="head">
                            <h4>200元</h4>
                            <p>20000书币+15000书币</p>
                        </div>
                        <div class="foot">
                        多送150元
                        </div>
                    </li>
                </ul>
                <div :class="['vip',sum == 4?'vipcon':'']" @click="sum = 4">
                    <h2>包年畅读VIP会员</h2>
                    <h3>¥365.00</h3>
                    <span>每天1元，全年免费看</span>
                </div>
                <div class="btn" @click="payGo">立即充值</div>
            </div>
            <!-- 搜索框 -->
            <router-link tag="div" to="/search" class="search">
                <div class="search_wrap">
                    <input type="text">
                    <button></button>
                </div>
            </router-link>
            <!-- 页脚信息 -->
            <div class="footer">
                <div class="foot_tit">
                    <ul>
                        <li>
                            <a href="javascript:;">首页</a>
                        </li>
                        <li>
                            <a href="javascript:;">书库</a>
                        </li>
                        <li>
                            <a href="javascript:;">书架</a>
                        </li>
                        <li>
                            <a href="javascript:;">账户</a>
                        </li>
                        <li>
                            <a href="javascript:;">客户端</a>
                        </li>
                    </ul>
                </div>
                <div class="foot_cont">
                    <div class="foot_info">
                        <p>客服QQ群：326738643</p>
                        <p>客服电话：010-86462015-800</p>
                        <p>©2020北京爱书客科技有限公司</p>
                        <p>京ICP备13037522号</p>
                    </div>
                    <div class="info_img">
                        <img src="../assets/images/ledu.png" alt="">
                        <span>乐读书城</span>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
    export default {
        data() {
            return {
                isTop:false,//判断子菜单的展示
                paymode:0,//微信支付宝
                sum:0,//充值挡位
                pay:0,//书币
            };
        },
        
        methods:{
            topShow() {
                this.isTop = !this.isTop
            },
            payGo(){
                let pay = 0;
                if(this.sum == 4){
                     var today = new Date();
                     let date = today.getTime();
                     let datepay = true;

                    window.localStorage.setItem('date', date);
                    window.localStorage.setItem('datepay', datepay);

                }
                switch (this.sum) {
                    case 0:
                        pay = 3000;
                        break;
                    case 1:
                        pay = 5000+1000;
                        break;
                    case 2:
                        pay = 10000+5000;
                        break;
                    case 3:
                        pay = 20000+15000;
                        break;
                
                    default:
                        break;
                }
                window.localStorage.setItem('pay',pay);
                this.pay = pay;
                this.$toast("充值成功")
            }
        },
        
    }
</script>

<style lang="scss" scoped>
.nav {
    background-color: #fff;

    .nav_wrap {
        padding: 0 14px;
        border-bottom: 1px solid #e0e0e0;
        display: flex;

        .quit {
            width: 10px;
            height: 45px;
            background-image: url('../assets/images/quit.png');
            background-repeat: no-repeat;
            background-size: 100%;
            background-position: center;
        }

        span {
            color: #333;
            font-size: 16px;
            display: block;
            text-align: center;
            line-height: 45px;
            width: 54%;
            padding-left: 70px;
        }

        .nav_icon {
            display: flex;
            align-items: center;
            justify-content: space-between;
            width: 80px;

            a {
                display: block;
                width: 25px;
                height: 22px;
                background-image: url('../assets/images/book_ico1.png');
                background-repeat: no-repeat;
                background-size: 100%;
                background-position: center;
            }

            i {
                display: block;
                width: 20px;
                height: 20px;
                background-image: url('../assets/images/bookMore_ico1.png');
                background-size: 100%;
                background-position: center;

            }

            .topnav {
                background-image: url('../assets/images/tp_close.png');
            }
        }
    }
}

.wrap {
    position: fixed;
    top: 45px;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: rgba(0, 0, 0, .8);
    z-index: 10;
    .subnav {
        width: 100%;
        background-color: #fff;
        padding-bottom: 18px;

        ul {
            display: flex;
            flex-wrap: wrap;

            li {
                width: 25%;
                text-align: center;
                padding-top: 20px;

                img {
                    width: 40px;
                    height: 40px;
                    margin: 0 auto 8px auto;
                }

                span {
                    font-size: 13px;
                    color: #666;
                }
            }
        }
    }

}
.set_money{
    padding: 0 17.5px;
    p{
        color: #999;
        font-size: 15px;
        line-height: 42px;
    }
}

.pay_option{
    padding: 0 14px 14px;
    .pay_tit{
        display: flex;
        div{
            flex: 1;
            border: 1px solid #ea4136;
            font-size: 17.5px;
            color: #ea4136;
            line-height: 40px;
            text-align: center;
        }
        .con{
            color: #fff;
            background-color: #ea4136;
        }
    }
    ul{
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
        li{
            width: 47%;
            height: 85px;
            border: 1px solid #ef6c63;
            background-color: #fff6f5;
            margin-top: 14px;
            .head{
                width: 100%;
                height: 37px;
                color: #ea4136;
                text-align: center;
                padding: 10px 0 7px 0;
                border-bottom: 1px dashed #ea4136;
                h4{
                    font-size: 16px;
                    font-weight: normal;
                }
                p{
                    font-size: 13px;
                }
            }
            .foot{
                line-height: 30px;
                text-align: right;
                color: #ef6c63;
                padding-right: 13px;
            }
        }
        .con{
            &>.head{
                background-color: #f66e64;
                color: #fff;
            }
        }
    }
    .vip{
        width: 346px;
        height: 85px;
        margin: 12px auto 0 auto;
        background-image: url('../assets/images/vip.jpg');
        background-size: 100%;
        text-align: center;
        h2{
            font-size: 17.5px;
            color: #b08544;
            line-height: 30px;
            &::before{
                content: '';
                width: 26px;
                height: 23px;
                display: inline-block;
                vertical-align: middle;
                background-image: url('../assets/images/vipIco2.png');
                background-size: 23px;
                background-position: center;
                background-repeat: no-repeat;
            }
        }
        h3{
            font-size: 16px;
            color: #b08544;
            line-height: 25px;
        }
        span{
            font-size: 14.5px;
            color: #333;
            line-height: 15px;
        }
    }
    .vipcon{
        background-image: none;
        background-color: #f66e64;
        h2{
            color: #fff;
        }
        h3{
            color: #fff;
        }
        span{
            color: #fff;
        }
    }
    .btn{
        width: 100%;
        height: 45px;
        line-height: 45px;
        border-radius: 22px;
        background-color: #ea4136;
        color: #fff;
        text-align: center;
        font-size: 17px;
        margin-top: 23px;
    }
}

.bor_bot {
    border-bottom: 10px solid #eaeaea;
}

.search {
    padding: 10px 14px;

    .search_wrap {
        display: flex;
        padding: 4px 0 4px 17px;
        border: 1px solid #dbdbdb;
        height: 32px;
        border-radius: 20px;
        overflow: hidden;

        &>input {
            border: 0px;
            outline: none;
            flex: 6;
            color: #999;
        }

        &>button {
            flex: 1;
            background-image: url('../assets/images/searchBar.png');
            background-repeat: no-repeat;
            border: 0px;
            background-color: #fff;
            position: relative;
            border-left: 1px solid #dbdbdb;
            background-size: 18px;
            background-position: center;
        }
    }
}

.footer {
    padding: 16px 0px 32px 0px;
    background-color: #1c1a1a;

    .foot_tit {
        padding-bottom: 15px;

        ul {
            display: flex;

            li {
                flex: 1;

                a {
                    display: block;
                    font-size: 16px;
                    color: #b6b6b6;
                    text-align: center;
                    border-right: 1px solid #999999;

                }

                &:last-of-type {
                    a {
                        border: 0px;
                    }
                }
            }
        }
    }

    .foot_cont {
        display: flex;
        justify-content: space-between;
        padding: 0 16px;

        .foot_info {
            p {
                color: #b6b6b6;
                font-size: 12px;
                line-height: 28px;
            }
        }

        .info_img {
            img {
                width: 98px;
                height: 98px;
            }

            span {
                font-size: 12px;
                display: block;
                text-align: center;
                color: #b6b6b6;
                padding-top: 3px;
            }
        }
    }
}
</style>